let userInfo = {} // 用户信息

let statistice = {} // 用户统计信息

/**
 * 获取用户token
 */
export function getToken() {
  return uni.getStorageSync('tokens') || null
}

/**
 * 设置用户token
 * @param {String} token
 */
export function setToken(token) {
  uni.setStorageSync('tokens', token)
}

/**
 * 清除token
 */
export function removeToken() {
  uni.removeStorageSync('token')
}

/**
 * 获取用户信息
 */
export function getUserInfo() {
  return JSON.parse(JSON.stringify(userInfo))
}
/**
 * 设置用户信息
 * @param {Object} info
 */
export function setUserInfo(info) {
  userInfo = {
    ...userInfo,
    ...info
  }
}

/**
 * 获取个人统计信息
 */
export function getStatisticeInfo() {
  return JSON.parse(JSON.stringify(statistice))
}

/**
 * 设置个人统计信息
 * @param {Object} data
 */
export async function setStatisticeInfo() {
  const res = await getSelfStatistice()

  statistice = res.data
  return res.data
}
//根据文字匹配json格式内的数据
let devDate=
{"屏峰校区": 
[{"code": ["002000473", "002000472"], 
"location": "建工学院后面"}, 
{"code": ["002000330"], 
"location": "家和西4-5"}, 
{"code": ["002000225-1"], 
"location": "家和西6-7之间-20201208150820"}, 
{"code": ["002000254", "002000346", 
"002000337"], "location": "备用"}, 
{"code": ["002000326", "002000329", "002000403", "002000327", "002000328", "002000222", "002000224", "002000223"], 
"location": "家和西6-7之间"}, 
{"code": ["002000357", "002000356", "002000342", "002000343"], 
"location": "家和东2-3之间"}, {"code": ["002000407", "002000400"], 
"location": "东1南面"}, {"code": ["002000345", "002000338"], 
"location": "养贤府北面"}, {"code": ["002000352"], 
"location": "艺术楼左边"}, 
{"code": ["002000389", "002000390"], 
"location": "仁和楼"}, 
{"code": ["002000398"], 
"location": "计算机楼后面"}, 
{"code": ["002000348", "002000347"], 
"location": "家和食堂后面"}, 
{"code": ["002000221"], 
"location": "家和东苑12号楼"}, 
{"code": ["002000355"], 
"location": "家和东2幢至4幢之间"}, 
{"code": ["002000353"], 
"location": "家和东15幢后面"}, 
{"code": ["002000350", "002000228", "002000227", "002000226", "002000349"], 
"location": "计算机楼东面"}, 
{"code": ["002000399"], 
"location": "信息楼（增加）"}, 
{"code": ["002000333", "002000334"], 
"location": "家和西8幢"}, 
{"code": ["002000470", "002000471", "002000469", "002000404"], 
"location": "机械楼3号楼后面"}, 
{"code": ["002000402", "002000406"], 
"location": "机械学院3号楼后面"}, 
{"code": ["002000220"], 
"location": "家和东12号前"}, 
{"code": ["002000401", "002000410"], 
"location": "东13和14之间"}, 
{"code": ["002000336", "002000335"], 
"location": "家和东12幢"}, 
{"code": ["002000354"], 
"location": "艺术楼右边"}, 
{"code": ["002000392"], 
"location": "广知楼（6个位）"}, 
{"code": ["002000351"], 
"location": "信息楼后面"}, 
{"code": ["002000332", "002000331"], 
"location": "家和西4-5之间"}, 
{"code": ["002000337", "002000408"], 
"location": "东8北面"}, 
{"code": ["002000393"],
 "location": "广知楼"}, 
 {"code": ["002000344"], 
 "location": "家和东18幢"}, 
 {"code": ["002000229"], 
 "location": "家和东17幢"}], 
 "朝晖校区": [
{"code": ["002000294", "002000295"], 
	 "location": "毓秀堂前"}, 
{"code": ["002000314", "001002577"], 
	 "location": "机械楼边"}, 
{"code": ["002000325"], 
	 "location": "生物楼边"}, 
{"code": ["002000397"], 
	 "location": "游泳馆前"}, 
{"code": ["002000292", "001002576", "002000320", "002000319", "001002575"], 
	 "location": "东配楼"}, 
{"code": ["001002573"], 
	 "location": "尚德8幢前"},
{"code": ["002000324"],
	"location": "梦溪村2幢"}, 
{"code": ["002000322"],
	"location": "机械楼"}, 
{"code": ["002000321", "002000255"],
	"location": "毓秀堂后面"}, 
{"code": ["002000211", "002000316"], 
	"location": "尚德7幢前"}, 
	{"code": ["002000396"], 
	"location": "子良楼"}, 
	{"code": ["002000395"], 
	"location": "游泳馆前5个插座"},
	{"code": ["002000323", "002000293"], 
	"location": "梦溪村4幢"}, 
	{"code": ["001002574"], 
	"location": "尚德2幢前"}, 
	{"code": ["002000315"], 
	"location": "化学工程学院"}, 
	{"code": ["002000253", "002000394"], 
	"location": "精弘餐厅后面"}, 
	{"code": ["002000318", "002000317"], 
	"location": "尚德2幢"}, 
	{"code": ["002000485"], 
	"location": "尚德2前工具电动车5路"}], 
"莫干山校区": [
{"code": ["002000375", "002000374", "002000376"], 
		"location": "师生活动中心"}, 
{"code": ["002000365", "002000366"], 
		"location": "菜鸟驿站学生公寓1号楼"}, 
{"code": ["002000382", "002000380", "002000381", "002000358", "002000386"], 
		"location": "海洋学院"}, 
		{"code": ["002000373", "002000367", "002000371"], "location": "协同1号楼"}, 
		{"code": ["002000384", "002000379", "002000383", "002000387"], "location": "生物楼"}, 
		{"code": ["002000388", "002000372"], 
		"location": "药学院1号楼"}, 
		{"code": ["002000339", "002000340"], 
		"location": "学生楼8-9幢南面车棚"}, 
		{"code": ["002000363", "002000362", "002000385"], 
		"location": "协同2号楼"},
		{"code": ["002000378", "002000377"], 
		"location": "体育馆"},
		{"code": ["002000359", "002000360", "002000361"], 
		"location": "环境楼"}, {"code": ["002000364"],
		 "location": "学生公寓1号楼（菜鸟驿站）"}, 
		 {"code": ["002000341"],
		  "location": "后勤综合服务大厅"}, 
		  {"code": ["002000370", "002000369"],
		   "location": "校卫生所前"}, 
		   {"code": ["002000368"], 
		   "location": "食堂后面"}], 
		   "假山校区": 
		   [{"code": ["002000257"], 
		   "location": "002000257"}, 
		   {"code": ["002000256"], 
		   "location": "002000256"}, 
		   {"code": ["002000391"], 
		   "location": "食堂边"}]}

const  quyu=
{"屏峰校区":
{'家和东苑': ['家和东2-3之间', '家和东苑12号楼', '家和东2幢至4幢之间', 
 '家和东15幢后面', '家和东12号前', '家和东12幢',  '家和东18幢', '东1南面', '东13和14之间', 
 '东8北面',   '家和东17幢'],
'家和西苑': [ '家和西4-5', '家和西6-7之间','家和西6-7之间', '家和西8幢',  '家和西4-5之间'],
'生活区': [ '家和食堂后面',  '养贤府北面'] ,
'老教学区': ['老教学区', '广知楼（6）', '广知楼', '仁和楼' ],
'新教学区': [ '机械楼3号楼后面', '机械学院3号楼后面', '计算机楼后面', '计算机楼东面',
   '建工学院后面',  '信息楼（增加）', '信息楼后面', '艺术楼左边', '艺术楼右边']
},
"朝晖校区":
{
	'食堂': [ '毓秀堂前', '毓秀堂后面',  '精弘餐厅后面'],
	'宿舍楼': [ '梦溪村2幢', '梦溪村4幢',  '尚德8幢前', '尚德7幢前', '尚德2幢前', '尚德2幢',   '尚德2前工具电动车5路'],
	'教学区': [ '东配楼',   '化学工程学院', '机械楼边', '机械楼',  '生物楼边', '游泳馆前', '游泳馆前(5)', '子良楼'],
	"食堂":["食堂后面"],
},

"莫干山校区":{
'学生公寓': [ '菜鸟驿站学生公寓1号楼',  '学生楼8-9幢南面车棚',  '学生公寓1号楼'],
'服务大厅': [ '后勤综合服务大厅'],
'教学区': [ '海洋学院',  '环境楼',  '生物楼','师生活动中心',  '体育馆', '协同1号楼', 
'协同2号楼','药学院1号楼',  '校卫生所前']

}
}
const school={
	"屏峰校区":["家和东苑",'家和西苑','生活区','老教学区','新教学区'],
	"朝晖校区":['食堂','宿舍楼','教学区',"食堂"],
	"莫干山校区":['学生公寓','服务大厅','教学区']
}

export function getquyu(sc){
	return school[sc]
}
export function getlocation(school,region)
{
	const date=quyu[school]
	return date[region]	
}

export function  getCode(school,local){
	let date=devDate[school]
	
	for(let i=0;i<date.length;i++)
	{
		if(date[i].location===local)
		{
			console.log(date[i].code)
			return date[i].code
		}
	}
}